//
//  HMRetweetsdStatusCell.swift
//  weibo10
//
//  Created by mac on 15/10/25.
//  Copyright © 2015年 itheima. All rights reserved.
//

import UIKit

class HMRetweetsdStatusCell: HMStatusCell {
    override var viewModel: HMStatusViewModel? {
        didSet {
            retweetedText.text = viewModel?.retweetedText
            picView.snp_updateConstraints { (make) -> Void in
                let offset = viewModel?.thumbnailUrls?.count > 0 ? statusCellMargin : 0
                make.top.equalTo(retweetedText.snp_bottom).offset(offset)
            }
        }
    }
    /// 懒加载控件
    // 背景按钮
    private lazy var backBtn: UIButton = {
       let btn = UIButton()
        btn.backgroundColor = UIColor(white: 0.95, alpha: 1.0)
        return btn
    }()
    
    // 转发微博的文字
    private lazy var retweetedText: UILabel = UILabel(title: "转发微博转发微博转发微博转发微博转发微博转发微博转发微博转发微博转发微博", inset: statusCellMargin)
}

// MARK: -设置界面
extension HMRetweetsdStatusCell {
    /// 设置界面
    override func setupUI() {
        super.setupUI()
        // 添加控件
        contentView.insertSubview(backBtn, belowSubview: picView)
        contentView.insertSubview(retweetedText, aboveSubview: backBtn)
        // 布局
        backBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(txtLabel.snp_bottom).offset(statusCellMargin)
            make.left.equalTo(contentView.snp_left)
            make.right.equalTo(contentView.snp_right)
            make.bottom.equalTo(bottomView.snp_top)
        }
        retweetedText.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(backBtn.snp_top).offset(statusCellMargin)
            make.left.equalTo(backBtn.snp_left).offset(statusCellMargin)
        }
        picView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetedText.snp_bottom).offset(statusCellMargin)
            make.left.equalTo(retweetedText.snp_left)
            make.width.equalTo(300)
            make.height.equalTo(90)
        }

    }
}
